package com.zyz.forum.service.impl;

import com.aliyun.oss.ServiceException;
import com.zyz.forum.file.OSSResult;
import com.zyz.forum.file.OSSService;
import com.zyz.forum.model.User;
import com.zyz.forum.service.IFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Service
public class FilServiceImpl implements IFileService {

    @Autowired
    private OSSService ossService;

    @Override
    public OSSResult uploadFile(MultipartFile file, User user) {
        try {
            return ossService.uploadFile(file,user);
        } catch (Exception e) {
            log.error("上传文件失败 error:{}", e.getMessage());
            throw new ServiceException("头像上传失败...");
        }
    }
}
